<!DOCTYPE html>
<html>

<head>
    <#include "/xhc/admin/components/meta.html" />
    <title>出出帮火车奇妙世界后台 ${metaTitleSuffix!}</title>
    <#include "/xhc/admin/components/stylesheets.html" />
    <style>
        .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="3-1" />
            <#include "/xhc/admin/components/menu.html" />
            <el-container>
                <#include "/xhc/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-form ref="form" :model="form" label-width="80px">
                            <el-row :gutter="20">
                                <el-col :span="24">
                                    <el-form-item label="标题">
                                        <el-input v-model="form.title"></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="24">
                                    <el-form-item label="链接">
                                        <el-input v-model="form.url" type='text'></el-input>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="24">
                                    <el-form-item label="封面">
                                        <el-upload class="avatar-uploader" :on-success="handleAvatarSuccess" :http-request='onUploadSMImage' list-type='picture' :show-file-list="false">
                                            <img v-if="form.image" :src="form.image" class="avatar">
                                            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                        </el-upload>
                                    </el-form-item>
                                </el-col>
                                <el-col>
                                    <el-form-item>
                                        <el-button type="primary" @click="onSubmit">保存</el-button>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </el-form>
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/xhc/admin/components/footer.html" />
    </div>
    <#include "/xhc/admin/components/scripts.html" />
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                form: {
                    title: `${info.title!''}`,
                    image: `${info.image!''}`,
                    url: `${info.url!''}`,
                    id: `${info.id!''}`,
                    type: `${info.type!''}`,
                }
            }
        },
        mounted: function() {},
        methods: {
            onSubmit() {
                var param = {
                    id: this.form.id,
                    type: this.form.type,
                    title: this.form.title,
                    url: this.form.url,
                    image: this.form.image
                }
                // console.log(param)
                var url = ''
                var ref = '${referer!""}'
                var url = '/xhc/web/adv/submit'
                axiosRequest(param, url, ref)
            },
            fileChanged(file, fileList) {
                console.log(file)
                console.log(fileList)
                console.log(this.fileList2)
                this.imgDatas = fileList
                // console.log(fileList2)
                // console.log(this.imgDatas)
            },
            handleAvatarSuccess(res, file) {
                this.form.image = res.data.url
                // this.form.cover = URL.createObjectURL(file.raw);
            },
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
    <script>
    // vue.tableData = ${items!};
    </script>
</body>

</html>